/*
 * This class holds the information about the track of the CD
 */
package edu.iyte.ceng431.hw03.cdplayer.model;

/**
 *
 * @author CUNEYT
 */
public class Track {

    private String title;
    private String artist;
    private int year;
    private String album;
    private int length;

    public Track(String title, String artist, int year, String album, int length) {
        this.title = title;
        this.artist = artist;
        this.year = year;
        this.album = album;
        this.length = length;
    }

    /**
     * @return the title
     */
    public String getTitle() {
        return title;
    }

    /**
     * @param title the title to set
     */
    public void setTitle(String title) {
        this.title = title;
    }

    /**
     * @return the artist
     */
    public String getArtist() {
        return artist;
    }

    /**
     * @param artist the artist to set
     */
    public void setArtist(String artist) {
        this.artist = artist;
    }

    /**
     * @return the year
     */
    public int getYear() {
        return year;
    }

    /**
     * @param year the year to set
     */
    public void setYear(int year) {
        this.year = year;
    }

    /**
     * @return the album
     */
    public String getAlbum() {
        return album;
    }

    /**
     * @param album the album to set
     */
    public void setAlbum(String album) {
        this.album = album;
    }

    /**
     * @return the length
     */
    public int getLength() {
        return length;
    }

    //Returns the length of the track in a formatted way as hh:mm:ss
    public String getFormattedLength() {
        int second = length, hour = 0, minute = 0;
        StringBuilder time = new StringBuilder();
        time.append(hour = second / 3600);
        time.append(":");
        time.append(minute = (second - hour * 3600) / 60);
        time.append(":");
        time.append((second - hour * 3600 - minute * 60));
        return time.toString();
    }

    /**
     * @param length the length to set
     */
    public void setDuration(int length) {
        this.length = length;
    }
}
